/******************************************************************************
*   Project:		DotNetCRM 
*	Filename:		ILocation.cs
*	Author:			Kristopher Cargile <kris@kriscargile.com>
*	Date Created:	07/02/2008
*******************************************************************************
*	Change History: 
*******************************************************************************
* IMPORTANT GNU LICENSE INFORMATION. DO NOT REMOVE THIS SECTION!
*
* DotNetCRM :: Copyright (c) 2005-2008, Cargile Technology Group, LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
******************************************************************************/

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Data;

namespace DotNetCRM.Core
{
	/// <summary>
	/// A physical location.
	/// </summary>
    [Serializable]
    [DataContract]
	public class Location : DomainObject
	{
        /// <summary>
        /// Address list for this this location.
        /// </summary>
        public virtual IList<Address> Addresses { get; set; }

        /// <summary>
        /// True if this is the deafault location; otherwise, false.
        /// </summary>
        public virtual bool IsDefault { get; set; }

        /// <summary>
        /// Initialize a new instance of the Location class.
        /// </summary>
        public Location() : base() { }

        /// <summary>
        /// Loads an object from persistent storage. 
        /// </summary>
        /// <param name="id">Id of the record to load.</param>
        public override void Load(int id)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Loads a list of objects from persistent storage. 
        /// </summary>
        public static Location[] Load()
        {
            // TODO: what's the best way to handle selection criteria?
            throw new NotImplementedException();
        }

        /// <summary>
        /// Adds or updates the object in persistent storage. 
        /// </summary>
        /// <param name="txn">An <see cref="IDbTransaction"/> to execute the 
        /// operation within.</param>
        /// <returns>Number of records affected.</returns>
        public override int Save(IDbTransaction txn)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Adds or updates a batch of objects in persistent storage. 
        /// </summary>
        /// <param name="list">List of records to add or update.</param>
        /// <returns>Number of records affected.</returns>
        public static int Save(Location[] list)
        {
            return Location.Save(list, null);
        }

        /// <summary>
        /// Adds or updates a batch of objects in persistent storage. 
        /// </summary>
        /// <param name="list">List of records to add or update.</param>
        /// <param name="txn">An <see cref="IDbTransaction"/> to execute the 
        /// operation within.</param>
        /// <returns>Number of records affected.</returns>
        public static int Save(Location[] list, IDbTransaction txn)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Deletes the object from persistent storage. 
        /// </summary>
        /// <param name="txn">An <see cref="IDbTransaction"/> to execute the 
        /// operation within.</param>
        /// <returns>Number of records affected.</returns>
        public override int Delete(IDbTransaction txn)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Deletes a batch of objects from persistent storage. 
        /// </summary>
        /// <param name="list">List of records to add or update.</param>
        /// <returns>Number of records affected.</returns>
        public static int Delete(Location[] list)
        {
            return Location.Delete(list, null);
        }

        /// <summary>
        /// Deletes a batch of objects from persistent storage. 
        /// </summary>
        /// <param name="list">List of records to add or update.</param>
        /// <param name="txn">An <see cref="IDbTransaction"/> to execute the 
        /// operation within.</param>
        /// <returns>Number of records affected.</returns>
        public static int Delete(Location[] list, IDbTransaction txn)
        {
            throw new NotImplementedException();
        }
    }

    #region Old code to possibly factor in

    ///// <summary>
    ///// Represents a physical business entity.
    ///// </summary>
    //public interface IBusinessEntity : INullable
    //{
    //    /// <summary>
    //    /// When implemented in a class, gets or sets the industry type id.
    //    /// </summary>
    //    /// <value>A Guid containing the unique identifier for the insustry that this entity belongs to.</value>
    //    IdentityField IndustryTypeId { get; set; }

    //    /// <summary>
    //    /// Gets or sets the address.
    //    /// </summary>
    //    /// <value>An <see cref="List"/> of <see cref="IAddress"/> objects.</value>
    //    List<IAddress> Address { get; set; }

    //    /// <summary>
    //    /// When implemented in a class, gets or sets the website address for this entity.
    //    /// </summary>
    //    /// <value>A string containg a valid HTTP url. Do not include the protocol.</value>
    //    String Url { get; set; }

    //    /// <summary>
    //    /// When implemented in a class, gets or sets the number of years this entity has been open for business.
    //    /// </summary>
    //    /// <value>An int containing the number of years this entity has been open for business.</value>
    //    Nullable<int> YearsOpen { get; set; }

    //    /// <summary>
    //    /// When implemented in a class, gets or sets the location's telephone number.
    //    /// </summary>
    //    /// <value>A string containing the location's telephone number.</value>
    //    IPhoneNumber Telephone { get; set; }

    //    /// <summary>
    //    /// When implemented in a class, gets or sets the location's telephone number.
    //    /// </summary>
    //    /// <value>A string containing the location's fax number.</value>
    //    IPhoneNumber Fax { get; set; }
    //}

    ///// <summary>
    ///// Represents a location.
    ///// </summary>
    //public abstract class AbstractLocation : DomainObject, IBusinessEntity
    //{
    //    AddressCollection _address;
    //    IPhoneNumber _fax;
    //    IdentityField _industryTypeId;
    //    NullableBoolean _default;
    //    IPhoneNumber _telephone;
    //    string _url;
    //    NullableInt32 _yearsOpen;

    //    /// <summary>
    //    /// Gets or sets this locations default status.
    //    /// </summary>
    //    /// <value>A <see cref="NullableBoolean"/> indicating whether 
    //    /// this is the default location.</value>
    //    public NullableBoolean IsDefault
    //    {
    //        get { return _default; }
    //        set { _default = value; }
    //    }

    //    /// <summary>
    //    /// Initialize a new instance of the AbstractLocation class.
    //    /// </summary>
    //    public AbstractLocation()
    //    {
    //        Clear();
    //    }

    //    /// <summary>
    //    /// When implmented in a subclass, clears members.
    //    /// </summary>
    //    public override void Clear()
    //    {
    //        Address = new AddressCollection();
    //        Fax = new USPhoneNumber();
    //        IndustryTypeId = new IdentityField(Framework.Common.Globals.NULL_ID);
    //        IsDefault = NullableBoolean.Null;
    //        Telephone = new USPhoneNumber();
    //        Url = string.Empty;
    //        YearsOpen = NullableInt32.Null;
    //        CreatorId = new IdentityField(Framework.Common.Globals.NULL_ID);
    //        DateCreated = DateTime.Now;
    //        DateLastModified = DateTime.Now;
    //        Id = new IdentityField(Framework.Common.Globals.NULL_ID);
    //        LastModifiedById = Context.Current.Id;
    //        Name = string.Empty;
    //        RecordVersion = NullableInt32.Null;
    //    }

    //    /// <summary>
    //    /// When implmented in a subclass, saves the 
    //    /// location to persistent storage.
    //    /// </summary>
    //    public abstract override void Save();

    //    /// <summary>
    //    /// When implmented in a subclass, deletes the 
    //    /// location from persistent storage.
    //    /// </summary>
    //    public abstract override void Delete();

    //    #region IBusinessEntity Members

    //    /// <summary>
    //    /// When implemented in a class, gets or sets the industry type id.
    //    /// </summary>
    //    /// <value>A Guid containing the unique identifier for the 
    //    /// industry that this entity belongs to.</value>
    //    public IdentityField IndustryTypeId
    //    {
    //        get { return _industryTypeId; }
    //        set { _industryTypeId = value; }
    //    }

    //    /// <summary>
    //    /// Gets or sets the address.
    //    /// </summary>
    //    /// <value>An <see cref="AddressCollection"/>.</value>
    //    public AddressCollection Address
    //    {
    //        get { return _address; }
    //        set { _address = value; }
    //    }

    //    /// <summary>
    //    /// Gets or sets the website address for this entity.
    //    /// </summary>
    //    /// <value>A string containg a valid HTTP url. 
    //    /// Do not include the protocol.</value>
    //    public String Url
    //    {
    //        get { return _url; }
    //        set { _url = value; }
    //    }

    //    /// <summary>
    //    /// Gets or sets the number of years this entity 
    //    /// has been open for business.
    //    /// </summary>
    //    /// <value>A int containing the number of years this 
    //    /// entity has been open for business.</value>
    //    public NullableInt32 YearsOpen
    //    {
    //        get { return _yearsOpen; }
    //        set { _yearsOpen = value; }
    //    }

    //    /// <summary>
    //    /// Gets or sets the location's telephone number.
    //    /// </summary>
    //    /// <value>A string containing the location's 
    //    /// telephone number.</value>
    //    public IPhoneNumber Telephone
    //    {
    //        get { return _telephone; }
    //        set { _telephone = value; }
    //    }

    //    /// <summary>
    //    /// Gets or sets the location's telephone number.
    //    /// </summary>
    //    /// <value>A string containing the location's fax number.</value>
    //    public IPhoneNumber Fax
    //    {
    //        get { return _fax; }
    //        set { _fax = value; }
    //    }

    //    #endregion

    //    #region INullable Members

    //    /// <summary>
    //    /// Tests for a null object.
    //    /// </summary>
    //    /// <returns>A bool indicating null status.</returns>
    //    public override bool IsNull()
    //    {
    //        return (
    //            Address.Count == 0 &&
    //            Fax.IsNull() &&
    //            IndustryTypeId.IsNull() &&
    //            IsDefault.IsNull &&
    //            Telephone.IsNull() &&
    //            Url.Length == 0 &&
    //            YearsOpen.IsNull &&
    //            Id.IsNull() &&
    //            Name.Length == 0 &&
    //            RecordVersion.IsNull);
    //    }

    //    #endregion
    //}

    #endregion
}